package cn.dmrliu.edu.publish.bean;

import cn.dmrliu.edu.publish.util.DoubleUtil;
import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class ToolVideoChapter {
    String chapterId;
    String chapterName;
    Long playCt;
    Long durSum;
    Long playNum;


    public Double getAvgDur() {
        return DoubleUtil.toTwo((double) durSum / (double) playNum);
    }

    @Override
    public String toString() {
        return "{\n" +
                "  \"chapterName\": \"" + this.chapterName + "\",\n" +
                "  \"playCt\": \"" + this.playCt + "\",\n" +
                "  \"durSum\": \"" + this.durSum + "\",\n" +
                "  \"playNum\": " + this.playNum + ",\n" +
                "  \"avgDur\": " + this.getAvgDur() + "\n" +
                "}";
    }
}
